#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<queue>
#include<unordered_map>

using namespace std;

int maximumDetonation(vector<vector<int>>& bombs) {
    int n = bombs.size();
    auto isConnected = [&](int u, int v)->bool {
        long long dx = bombs[u][0] - bombs[v][0];
        long long dy = bombs[u][1] - bombs[v][1];
        return (long long)bombs[u][2] * bombs[u][2] >= dx * dx + dy * dy;
    };

    unordered_map<int, vector<int>> edges;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j && isConnected(i, j))
            {
                edges[i].push_back(j);
            }

    int res = 0;
    for (int i = 0; i < n; i++)
    {
        vector<bool> st(n);
        queue<int> q;
        int count = 1;
        q.push(i);
        st[i] = true;
        while (q.size())
        {
            int t = q.front();
            q.pop();
            for (auto e : edges[t])
            {
                if (st[e])   continue;
                q.push(e);
                st[e] = true;
                count++;
            }
        }
        res = max(res, count);
    }
    return res;
}

int main()
{
    vector<vector<int>> vv = { { 1,2,3 }, {2, 3, 1},{3, 4, 2},{4, 5, 3},{5, 6, 4} };
    maximumDetonation(vv);
    return 0;
}